home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / warp / sgi / warp.main.c < prev   
C/C++ Source or Header  |  1993-10-29  |  7KB  |  324 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "point3.h"
  4. #include "forms.h"
  5. #include "formsx.h"
  6. #include "panel.h"
  7. #include "api.h"
  8.  
  9. main() {
  10.  
  11.   foreground();
  12.   create_the_forms();
  13.   apiInit();
  14.   fl_show_form(MainForm, FL_PLACE_SIZE, TRUE, "Warp");
  15.  
  16.   while(1) {
  17.     apiCheckPipes();
  18.     fl_check_forms();
  19.   }
  20.  
  21. }
  22.  
  23. /* Button call-backs */
  24. void uiPreviewProc(FL_OBJECT *obj, long val) {
  25.   apiPreview();
  26. }
  27.  
  28. void ObjectProc(FL_OBJECT *obj, long val) {
  29.   apiTargetChanged();
  30. }
  31.  
  32. void uiOptionsProc(FL_OBJECT *obj, long val) {
  33.   fl_show_form(OptionsForm, FL_PLACE_SIZE, TRUE, "Options");
  34. }
  35.  
  36. void uiWarpProc(FL_OBJECT *obj, long val) {
  37.   apiWarp();
  38. }
  39.  
  40. void uiQuitProc(FL_OBJECT *obj, long val) {
  41.   apiExit();
  42. }
  43.  
  44. void uiEditPointProc(FL_OBJECT *obj, long val) {
  45.   apiEdit();
  46. }
  47.  
  48. void uiDeletePointProc(FL_OBJECT *obj, long val) {
  49.   apiDelete();
  50. }
  51.  
  52. void uiDeleteAllProc(FL_OBJECT *obj, long val) {
  53.   apiDeleteAll();
  54. }
  55.  
  56. void uiPositionProc(FL_OBJECT *obj, long val) {
  57.   apiPosition();
  58. }
  59.  
  60. void uiEditLocation(FL_OBJECT *obj, long val) {
  61.   apiEditLocation();
  62. }
  63.  
  64. void WidgetGeomProc(FL_OBJECT *obj, long val) {
  65.   apiUpdateGeom();
  66. }
  67.  
  68. void WidgetScaleProc(FL_OBJECT *obj, long val) {
  69.   apiUpdateScale();
  70. }
  71.  
  72. void uiOptionsDoneProc(FL_OBJECT *obj, long val) {
  73.   fl_hide_form(OptionsForm);
  74. }
  75.  
  76. /* Things implemented in machine-specific code to be called by common
  77.  * code */
  78. void uiFreeze() {
  79.   fl_deactivate_form(MainForm);
  80.   fl_deactivate_form(OptionsForm);
  81. }
  82.  
  83. void uiThaw() {
  84.   fl_activate_form(MainForm);
  85.   fl_activate_form(OptionsForm);
  86. }
  87.  
  88. void uiError(const char *str1, const char *str2, const char *str3) {
  89.   apiFreeze();
  90.   fl_set_object_label(error1, (char *)str1);
  91.   fl_set_object_label(error2, (char *)str2);
  92.   fl_set_object_label(error3, (char *)str3);
  93.   fl_show_form(ErrorForm, FL_PLACE_MOUSE, TRUE, "Warp");
  94.   while (fl_do_forms() != uiErrorOK);
  95.   fl_hide_form(ErrorForm);
  96.   apiThaw();
  97. }
  98.  
  99. /* The ui code and the api code call one another in a somewhat 
  100.  * convoluted way here. */
  101. void uiEdit(const char *name) {
  102.   FL_OBJECT *obj;
  103.   apiFreeze();
  104.   fl_show_form(EditForm, FL_PLACE_MOUSE, TRUE, (char *)name);
  105.   while (1) {
  106.     obj = fl_do_forms();
  107.     if (obj == uiEditCancel || obj == uiEditSet || obj == uiEditSetAll)
  108.       break;
  109.   }
  110.   if (obj == uiEditSet) apiEditSet();
  111.   else if (obj == uiEditSetAll) apiEditSetAll();
  112.   fl_hide_form(EditForm);
  113.   apiThaw();
  114. }
  115.  
  116. void uiSetTarget(const char *target) {
  117.   fl_set_input(uiObject, (char *)target);
  118. }
  119.  
  120. const char *uiGetTarget() {
  121.   return fl_get_input(uiObject);
  122. }
  123.  
  124. void uiSetCreateOnPick(int val) {
  125.   fl_set_button(uiCreateOnPick, val);
  126. }
  127.  
  128. int uiGetCreateOnPick() {
  129.   return fl_get_button(uiCreateOnPick);
  130. }
  131.  
  132. void uiAddWidget(const char *name, int index) {
  133.   if (index < fl_get_browser_maxline(uiPointBrowser))
  134.     fl_insert_browser_line(uiPointBrowser, index, (char *)name);
  135.   else fl_add_browser_line(uiPointBrowser, (char *)name);
  136. }
  137.  
  138. void uiSetSelectedWidget(int index) {
  139.   fl_select_browser_line(uiPointBrowser, index + 1);
  140. }
  141.  
  142. int uiGetSelectedWidget() {
  143.   return fl_get_browser(uiPointBrowser) - 1;
  144. }
  145.  
  146. void uiSetWidgetName(const char *name, int index) {
  147.   fl_replace_browser_line(uiPointBrowser, index + 1, (char *)name);
  148. }
  149.  
  150. const char *uiGetWidgetName(int index) {
  151.   return fl_get_browser_line(uiPointBrowser, index + 1);
  152. }
  153.  
  154. int uiWidgetIndex(const char *name) {
  155.   int i;
  156.   for (i = 1; i < fl_get_browser_maxline(uiPointBrowser) + 1; i++)
  157.     if (!strcmp(fl_get_browser_line(uiPointBrowser, i), (char *)name)) 
  158.       return i-1;
  159.   return -1;
  160. }
  161.  
  162. void uiDeleteWidget(int index) {
  163.   fl_delete_browser_line(uiPointBrowser, index + 1);
  164. }
  165.                     
  166. void uiSetStrengthBounds(float min, float max) {
  167.   fl_set_slider_bounds(uiStrength, min, max);
  168. }
  169.  
  170. void uiSetStrength(float strength) {
  171.   fprintf(stderr, "strength = %f\n", strength);
  172.   fl_set_slider_value(uiStrength, strength);
  173. }
  174.  
  175. float uiGetStrength() {
  176.   return fl_get_slider_value(uiStrength);
  177. }
  178.  
  179. void uiSetSmoothnessBounds(float min, float max) {
  180.   fl_set_slider_bounds(uiSmoothness, min, max);
  181. }
  182.  
  183. void uiSetSmoothness(float smoothness) {
  184.   fprintf(stderr, "smoothness = %f\n", smoothness);
  185.   fl_set_slider_value(uiSmoothness, smoothness);
  186. }
  187.  
  188. float uiGetSmoothness() {
  189.   return fl_get_slider_value(uiSmoothness);
  190. }
  191.  
  192. void uiSetPoint(Point3 *pt) {
  193.   flx_set_input_float(uiEditX, pt->x);
  194.   flx_set_input_float(uiEditY, pt->y);
  195.   flx_set_input_float(uiEditZ, pt->z);
  196. }
  197.  
  198. void uiGetPoint(Point3 *pt) {
  199.   pt->x = flx_get_input_float(uiEditX);
  200.   pt->y = flx_get_input_float(uiEditY);
  201.   pt->z = flx_get_input_float(uiEditZ);
  202. }
  203.  
  204. void uiSetSteps(int steps) {
  205.   flx_set_input_int(uiIntSteps, steps);
  206. }
  207.  
  208. int uiGetSteps() {
  209.   return flx_get_input_int(uiIntSteps);
  210. }
  211.  
  212. void uiSetStart(int start) {
  213.   flx_set_input_int(uiStartStep, start);
  214. }
  215.  
  216. int uiGetStart() {
  217.   return flx_get_input_int(uiStartStep);
  218. }
  219.  
  220. void uiSetEnd(int end) {
  221.   flx_set_input_int(uiEndStep, end);
  222. }
  223.  
  224. int uiGetEnd() {
  225.   return flx_get_input_int(uiEndStep);
  226. }
  227.  
  228. void uiSetIntToGV(int val) {
  229.   fl_set_button(uiIntToGV, val);
  230. }
  231.  
  232. int uiGetIntToGV() {
  233.   return fl_get_button(uiIntToGV);
  234. }
  235.  
  236. void uiSetIntToFiles(int val) {
  237.   fl_set_button(uiIntToFiles, val);
  238. }
  239.  
  240. int uiGetIntToFiles() {
  241.   return fl_get_button(uiIntToFiles);
  242. }
  243.  
  244. void uiSetAutoUpdate(int val) {
  245.   fl_set_button(uiAutoUpdate, val);
  246. }
  247.  
  248. int uiGetAutoUpdate() {
  249.   return fl_get_button(uiAutoUpdate);
  250. }
  251.  
  252. void uiSetRetain(int val) {
  253.   fl_set_button(uiRetain, val);
  254. }
  255.  
  256. int uiGetRetain() {
  257.   return fl_get_button(uiRetain);
  258. }
  259.  
  260. void uiSetPrefix(const char *prefix) {
  261.   fl_set_input(uiPrefix, (char *)prefix);
  262. }
  263.  
  264. const char *uiGetPrefix() {
  265.   return fl_get_input(uiPrefix);
  266. }
  267.  
  268. void uiSetPath(const char *path) {
  269.   fl_set_input(uiPath, (char *)path);
  270. }
  271.  
  272. const char *uiGetPath() {
  273.   return fl_get_input(uiPath);
  274. }
  275.  
  276. void uiSetWidgetGeom(const char *geom) {
  277.   fl_set_input(uiWidgetGeom, (char *)geom);
  278. }
  279.  
  280. const char *uiGetWidgetGeom() {
  281.   return fl_get_input(uiWidgetGeom);
  282. }
  283.  
  284. void uiSetWidgetSize(float size) {
  285.   flx_set_input_float(uiWidgetSize, size);
  286. }
  287.  
  288. float uiGetWidgetSize() {
  289.   return flx_get_input_float(uiWidgetSize);
  290. }
  291.  
  292. void uiSetRelativeSize(int val) {
  293.   fl_set_button(uiRelSize, val);
  294. }
  295.  
  296. int uiGetRelativeSize() {
  297.   return fl_get_button(uiRelSize);
  298. }
  299.  
  300. void uiSetGridX(int x) {
  301.   flx_set_input_int(uiGridX, x);
  302. }
  303.  
  304. int uiGetGridX() {
  305.   return flx_get_input_int(uiGridX);
  306. }
  307.  
  308. void uiSetGridY(int y) {
  309.   flx_set_input_int(uiGridY, y);
  310. }
  311.  
  312. int uiGetGridY() {
  313.   return flx_get_input_int(uiGridY);
  314. }
  315.  
  316. void uiSetGridZ(int z) {
  317.   flx_set_input_int(uiGridZ, z);
  318. }
  319.  
  320. int uiGetGridZ() {
  321.   return flx_get_input_int(uiGridZ);
  322. }
  323.      
  324.